package com.androidy;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class year2010 extends Activity implements OnClickListener, AnimationListener {
	ImageView graduate, programmer;
	TextView text;
	Button back;
	int steps;
	int text_time =1500;
	int map_time = 3000;
	int img_time = 3000;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about2010);
		TextView header = (TextView)this.findViewById(R.id.header);
		header.setText("University");
		LinearLayout head_layout = (LinearLayout)this.findViewById(R.id.natvigation);
		head_layout.setBackgroundResource(R.drawable.green);
		back = (Button)this.findViewById(R.id.back);
		graduate = (ImageView)this.findViewById(R.id.graduate);
		programmer = (ImageView)this.findViewById(R.id.programmer);
		graduate.setImageResource(R.drawable.graduate);
		programmer.setImageResource(R.drawable.programmer);
		back.setText("back");
		back.setOnClickListener(this);
        text = (TextView)this.findViewById(R.id.text);
		steps = 0;
		text.setVisibility(View.INVISIBLE);
		graduate.setVisibility(View.INVISIBLE);
		programmer.setVisibility(View.INVISIBLE);
		text_fade_in_out(true);
    }
	@Override
	public void onAnimationStart(Animation animation) {
		// TODO Auto-generated method stub

		if (steps == 0) {
			text.setVisibility(View.VISIBLE);
			text.setText("In 2010, University Graduration");
	    	text.bringToFront();
		} else if (steps == 1) {
		} else if (steps == 2) {
			text.setVisibility(View.VISIBLE);
			text.setText("University is not only providing knowledge,");
	    	text.bringToFront();
		} else if (steps == 3) {
		} else if (steps == 4) {
			text.setVisibility(View.VISIBLE);
			text.setText("but also broaden my horizon in technology.");
	    	text.bringToFront();
		} else if (steps == 5) {
		} else if (steps == 6) {
			graduate.setVisibility(View.VISIBLE);
			graduate.bringToFront();
		} else if (steps == 7) {
			text.setVisibility(View.VISIBLE);
			text.setText("I start my career as programmer in the comapny");
	    	text.bringToFront();
		} else if (steps == 8) {
		} else if (steps == 9) {
			text.setVisibility(View.VISIBLE);
			text.setText("which provided internship when I am studying.");
	    	text.bringToFront();
		} else if (steps == 10) {
		} else if (steps == 11) {
			programmer.setVisibility(View.VISIBLE);
			programmer.bringToFront();
		}  else if (steps == 12) {
			text.setVisibility(View.VISIBLE);
			text.setText("Developing in-house web application.");
	    	text.bringToFront();
		}  else if (steps == 13) {
		} else if (steps == 14) {
			text.setText("At the same time,");
	    	text.bringToFront();
		} else if (steps == 15) {
		} else if (steps == 16) {
			text.setVisibility(View.VISIBLE);
			text.setText("I started my studies,");
	    	text.bringToFront();
		} else if (steps == 17) {
		} else if (steps == 18) {
			text.setVisibility(View.VISIBLE);
			text.setText("Master in Computer Sicence.");
	    	text.bringToFront();
		} else if (steps == 19) {
		}
	}
    
	@Override
	public void onAnimationRepeat(Animation animation) {
		// TODO Auto-generated method stub
	}

	@Override
	public void onAnimationEnd(Animation animation) {
		// TODO Auto-generated method stub
		// intro1 in out
		if (steps == 0) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 1) {
			steps ++;
			text_fade_in_out(true);
		// Growth
		} else if (steps == 2) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 3) {
			steps ++;
			text_fade_in_out(true);
		} else if (steps == 4) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 5) {
			steps ++;
			text.setVisibility(View.INVISIBLE);
			img_in_out(graduate);
		} else if (steps == 6) {
			steps ++;
			graduate.setVisibility(View.INVISIBLE);
			text_fade_in_out(true);
		} else if (steps == 7) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 8) {
			steps ++;
			text_fade_in_out(true);
		} else if (steps == 9) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 10) {
			steps ++;
			text.setVisibility(View.INVISIBLE);
			img_in_out(programmer);
		} else if (steps == 11) {
			steps ++;
			programmer.setVisibility(View.INVISIBLE);
			text_fade_in_out(true);
		} else if (steps == 12) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 13) {
			steps ++;
			text_fade_in_out(true);
		} else if (steps == 14) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 15) {
			steps ++;
			text_fade_in_out(true);
		} else if (steps == 16) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 17) {
			steps ++;
			text_fade_in_out(true);
		} else if (steps == 18) {
			steps ++;
			text_fade_in_out(false);
		} else if (steps == 19) {
			steps ++;
			text.setVisibility(View.INVISIBLE);
			this.finish();
		} 
	}
	
	// Animate Sets

	public void text_fade_in_out(Boolean is_in){
		Animation am1 = null;
		if (is_in == true)
			am1 = new AlphaAnimation( 0, 1 );
		else
			am1 = new AlphaAnimation( 1, 0 );	
	    am1.setDuration( text_time );
	    am1.setRepeatCount( 0 );
	    text.setAnimation(am1);
	    am1.setAnimationListener(this);
	    am1.startNow();
	}
		
 	public void img_in_out(View v){
		Animation am1 = new TranslateAnimation( 480, -480, 0, 0);	
	    am1.setDuration( img_time );
	    am1.setRepeatCount( 0 );
	    v.setAnimation(am1);
	    am1.setAnimationListener(this);
	    am1.startNow();
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		this.finish();
	}
}
